/*
 * @Author: zhangzhen
 * @Date: 2023-01-10 13:03:11
 * @LastEditors: zhangzhen
 * @LastEditTime: 2023-02-15 08:56:21
 *
 */
import React, {FC, useState, useEffect} from 'react';
import {Form,Table} from 'antd';
// import {Table} from '@gwaapp/ease';

const FormItem = Form.Item;

const TableComponent: FC<any> = (props) => {
    const {
        label,
        name,
        rules,
        required,
        infoCome,
        isSearch,
        defaultValue,
        isShowInTable,
        columns,
        ...TableProps
    } = props;
    const [newColumns, setNewColumns] = useState(columns);

    useEffect(() => {
        setNewColumns(columns);
    }, [columns]);

    return (
        <FormItem
            label={label}
            name={name}
            rules={rules}
            required={required}
            initialValue={defaultValue}>
            <Table
                {...TableProps}
                columns={newColumns}
                pagination={false}
                style={{minHeight: '100px'}}
                locale={{
                    emptyText: <div style={{height: 10}} />,
                }}
            />
        </FormItem>
    );
};

export default TableComponent;
